package org.ns.summer.aop;

import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class MethodInvoke implements Joinpoint{

    private Object target;
    private Object[] args;
    private Method method;
    private Object proxy;
    private MethodProxy methodProxy;

    public MethodInvoke(Object proxy, Object target, Object[] args, Method method,MethodProxy methodProxy) {
        this.methodProxy = methodProxy;
        this.proxy = proxy;
        this.target = target;
        this.args = args;
        this.method = method;
    }
    @Override
    public Object getProxy() {
        return proxy;
    }

    @Override
    public Object proceed() throws Throwable {
        return methodProxy.invoke(target, args);
    }
    @Override
    public Object proceedProxy() throws Throwable {
        return methodProxy.invokeSuper(proxy, args);
    }

    @Override
    public Object getThis() {
        return target;
    }

    @Override
    public Method getMethod() {
        return method;
    }

    @Override
    public Object[] args() {
        return args;
    }

}
